package com.echat.business.book.wrapper;

import com.echat.core.utils.ValueUtils;

import java.util.List;
import java.util.Map;

/**
 * 书籍信息wrapper
 */
public class AnnouncementWarpper {

    private List<Map<String, Object>> wrapperObj;

    public AnnouncementWarpper(List<Map<String, Object>> obj) {
        this.wrapperObj = obj;
    }

    /**
     * 包装 wrapperObj
     */
    public List<Map<String, Object>> wrap() {
        for (Map<String, Object> map : this.wrapperObj) {
            //公告类型反显
            if (map.get("type") != null) {
                int type = ValueUtils.parseInt(map.get("type"));
                String typeValue = "";
                switch (type) {
                    case 1:
                        typeValue = "公告";
                        break;
                    case 2:
                        typeValue = "新闻";
                        break;
                    case 3:
                        typeValue = "活动";
                        break;
                    case 4:
                        typeValue = "书讯";
                        break;
                    case 5:
                        typeValue = "故事";
                        break;
                    default:
                        typeValue = "公告";
                        break;
                }
                map.put("type", typeValue);
            }

        }
        return this.wrapperObj;
    }
}
